<template>
  <div class="mwDetailBox">
    <div class="topBox">
      <p>初步研判</p>
      <a-icon
        type="close"
        @click="onClose"
        :style="{ fontSize: '16px', color: '#525252', float: 'right', margin: '10px' }"
      />
    </div>
    <div class="box box1">
      <a-row style="margin-bottom:10px;">
        <a-col :span="24">
          <span>模型名称：</span><span>{{ rowData.modelName }}</span>
        </a-col>
      </a-row>
      <a-row style="margin-bottom:10px;">
        <a-col :span="24">
          <span>情报更新时间：</span><span>{{ rowData.updateTime }}</span>
        </a-col>
      </a-row>
    </div>
    <div class="box box2">
      <p>情报规则:</p>
      <a-tabs>
        <a-tab-pane key="1" tab="入岛">
          <a-row style="margin-bottom:10px;">
            <a-col :span="24">
              <span>进入区域：</span>
              <template v-if="modelRule.in != undefined && modelRule.in.areas != undefined">
                <a-tag v-for="(item, index) in modelRule.in.areas" :key="index">{{ item.areaName }}</a-tag>
              </template>
            </a-col>
          </a-row>
          <a-row style="margin-bottom:10px;">
            <a-col :span="24">
              <span>情报规则：</span>前<a-input
                class="input"
                v-model="inBeforeHours"
                :disabled="true"
              />小时岛内无信令位置信息，然后在区域内出现信令的人员
            </a-col>
          </a-row>
        </a-tab-pane>
        <a-tab-pane key="2" tab="出岛" force-render>
          <a-row style="margin-bottom:10px;">
            <a-col :span="24">
              <span>进入区域：</span>
              <template v-if="modelRule.out != undefined && modelRule.out.areas != undefined">
                <a-tag v-for="(item, index) in modelRule.out.areas" :key="index">{{ item.areaName }}</a-tag>
              </template>
            </a-col>
          </a-row>
          <a-row style="margin-bottom:10px;">
            <a-col :span="24">
              <span>情报规则：</span>前<a-input
                class="input"
                :disabled="true"
                v-model="outBeforeHours"
              />小时岛内有信令位置信息，然后在区域内出现信令后又无位置信息时长达
              <a-input class="input" v-model="outAfterMinutes" :disabled="true" />分钟
            </a-col>
          </a-row>
        </a-tab-pane>
      </a-tabs>
    </div>
    <div class="box box3">
      <p>基本信息:</p>
      <a-row style="margin-bottom:10px;">
        <a-col :span="10">
          <span>手机号：</span><span>{{ rowData.phone }}</span>
        </a-col>
        <a-col :span="14">
          <span>归属地：</span><span>{{ rowData.phoneArea }}</span>
        </a-col>
      </a-row>
    </div>
    <div class="box box4">
      <p>详细信息:</p>
      <CustomTable
        ref="table"
        :showAlert="false"
        :columns="columns"
        :dataSource="pageData"
        :showSelection="false"
        :showPagination="true"
        rowKey="id"
        @change="onTableChange"
      >
        <template slot="intelligenceType" slot-scope="text">
          <span v-if="text == '1'">异常入岛</span>
          <span v-if="text == '2'">异常出岛</span>
        </template>
      </CustomTable>
    </div>
  </div>
</template>
<script>
import * as api from '@/api/wxSmuggle/intelligence.js'
import CustomTable from '@/components/zxd/Table/CustomTable'
export default {
  props: ['visible'],
  components: {
    CustomTable
  },
  data() {
    return {
      pageFilter: {
        pageNo: 1,
        pageSize: 10
      },
      pageData: {},
      columns: [
        {
          title: '出现时间',
          dataIndex: 'appearTime',
          // width: 100,
          align: 'center',
          scopedSlots: { customRender: 'appearTime' }
        },
        {
          title: '当前位置',
          dataIndex: 'posName',
          align: 'center',
          // width: 110,
          scopedSlots: { customRender: 'posName' }
        },
        {
          title: '情报类型',
          dataIndex: 'intelligenceType',
          align: 'center',
          // width: 100,
          scopedSlots: { customRender: 'intelligenceType' }
        }
      ],
      rowData: {},
      modelRule: {},
      inBeforeHours: '',
      outBeforeHours: '',
      outAfterMinutes: ''
    }
  },
  mounted() {
    // this.refreshTable()
  },
  methods: {
    show(row) {
      this.pageFilter.id = row.id
      this.rowData = row
      this.modelRule = row.modelRule
      this.inBeforeHours = row.modelRule.in.beforeHours
      this.outBeforeHours = row.modelRule.out.beforeHours
      this.outAfterMinutes = row.modelRule.out.afterMinutes
      this.refreshTable()
    },
    refreshTable() {
      this.loading = true
      api
        .crypoIntellDetail(this.pageFilter)
        .then(res => {
          if (res.success) {
            this.pageData = res.result
            this.loading = false
            // this.$refs.table.onClearRowKeys()
          } else {
            this.loading = false
          }
        })
        .catch(e => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.refreshTable()
    },
    onClose(value) {
      this.$emit('close', value)
    }
    // onClickRow(row, n) {
    //   this.active = n
    //   this.$emit('on-click-row', row)
    // },
  }
}
</script>

<style lang="less" scoped>
.mwDetailBox {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 500px;
  background-color: #fff;
  .topBox {
    background-color: #f2f2f2 !important;
    overflow: hidden;
    p {
      float: left;
      color: #000;
      padding: 15px 10px 0;
      font-weight: 500;
      font-size: 16px;
      // line-height: 22px;
    }
    /deep/.anticon {
      float: right;
      margin: 10px;
    }
  }
  .box {
    padding: 0 10px;
    margin-left: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    p {
      font-weight: bold;
    }
    span {
      color: #000;
    }
  }
  .add-box {
    position: absolute;
    right: 10px;
    top: 100px;
  }
}
.editable-row-operations {
  a {
    color: #108de9;
  }
}
.input {
  width: 60px;
  margin: 5px 6px;
}
/deep/.ant-col-15 {
  width: 65%;
}
// .py_list_drawer tr:hover > td {
//   cursor: !important;
// }
// .mwDetailTable .spanBtn {
//   width: 100%;
//   display: inline-block;
//   cursor: pointer;
// }
</style>
